<template>
	<block>
		<hxt-layout id="hxt-layout" title="课表" svc="scCACourse" initTitle="课表加载失败" @initPage="initPage">
			<view class="hxt-flex-column" style="background-color: #F5F5F5;">

				<hxt-weekcalendars v-model="date" :list="weekList" @click="getSchedule"></hxt-weekcalendars>
				<view class="hxt-flex-fill" style="height: 1px;overflow-y: scroll;">
					<van-empty v-if="!list||list.length==0" description="今天没有课" />
					<template v-else>
						<view class="padding-tb-sm" v-for="(item,index) in list" :key="index">
							<van-cell-group inset>
								<van-cell :border="false">
									<template #title>
										<van-tag color="#ffe1e1" text-color="#ad0000" class="margin-right-sm"
											size="medium">课程</van-tag> {{item.cilName}}
									</template>
								</van-cell>
								<van-cell title-style="flex:none;min-width:150rpx;" title="上课时间" :border="false">
									{{item.cliStartTime}} 到 {{item.cliFinishTime}}
								</van-cell>
								<van-cell title-style="flex:none;min-width:150rpx;" title="上课地点" :border="false">
									{{item.liName}}
								</van-cell>
							</van-cell-group>
						</view>

					</template>
				</view>
			</view>
		</hxt-layout>
	</block>
</template>
<script>
	import hxt from "@/utils/hxt.js"
	var list = [];
	export default {
		data() {
			const app = getApp();
			return {
				list: [],
				show: false,
				currentUser: app.globalData.currentUser,
				minDate: new Date(hxt.dateConfig().monthBegin).getTime(),
				maxDate: new Date(hxt.dateConfig().monthEnd).getTime(),
				objList: [],
				date: hxt.dateFormat("yyyy-MM-dd"),
				weekList:[],
			}
		},
		onShow: function(e) {
			
		},
		watch: {
			date: function(val) {
				var _this = this;
				_this.loadList();
			}
		},
		computed: {

		},
		methods: {
			initPage: function(e) { //初始化事件
				var _this = this;
				_this.getSchedule();
				_this.loadList();
			},
			getSchedule:function(){
				var _this = this;
				hxt.post({
					url: hxt.domain + 'pc/wxGetSchedule',
					data: {
						date: _this.date
					},
					ok: function(res) {
						if (res.data.code != 0) return hxt.Notify({
							type: 'danger',
							message: '加载失败：：' + res.data.errmsg
						});
						_this.weekList = res.data.data;
					},
					fail: function(res) {
						hxt.Notify({
							type: 'danger',
							message: '加载失败：' + res.errMsg
						});
					}
				});
			},
			loadList: function() {
				var _this = this;
				hxt.post({
					url: hxt.domain + 'pc/wxGetScheduleTaskList',
					data: {
						date: _this.date
					},
					ok: function(res) {
						if (res.data.code != 0) return hxt.Notify({
							type: 'danger',
							message: '加载失败：：' + res.data.errmsg
						});
						_this.list = res.data.data;
					},
					fail: function(res) {
						hxt.Notify({
							type: 'danger',
							message: '保存失败：' + res.errMsg
						});
					}
				});
			}
		}
	}
</script>

<style>
	.txt-css {
		word-break: break-all;
		word-wrap: break-word;
		white-space: pre-line;
	}

	.submit-bar {
		position: sticky !important;
		z-index: 0 !important;
	}

	.van-button {
		height: 100% !important;
	}
</style>